import axios from "axios";
import * as api from "../../api/gw/index.js";
export default function (params, callback, fail) {
    let options = {
        method: "post",
        data: params,
        url: window.api.base_host + api.template_add,
        headers: {sessionId: getCookie("sessionId")}
    }

    axios(options).then(data => {
        if (data.status === 200 && data.data.returnCode === 1 && data.data.data[0]) {
            console.log("更新模板的数据",data.data.data)
            if (params.rid) {
                console.log("更新模板成功");
            } else {
                console.log("新增模板成功");
            }
            callback && callback(data.data.data);

        } else {
            fail && fail(data.data.msg);
        }
    }).catch(err => {
        fail && fail();
    });

}